﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using WebBrowserTest.AnalyzeResults;

namespace WebBrowserTest.Analyzers
{
    class YahooDirAnalyzer : AbstractAnalyzer
    {

        public YahooDirAnalyzer()
        {
            _lookupExpr = @"\d+ of about (.+) for|<p>(No) Directory Search results were found.</p>";
        }

        public override AbstractAnalyzeResult GetAnalyseResult(string html, string url)
        {
            var matches = Regex.Matches(html, _lookupExpr);
            var yDirSitesCount = 0;
            var cacheDate = new DateTime();
            for (var i = 0; i < matches.Count; i++)
            {
                var oDirSitesString = matches[i].Groups[1].Value;
                if (int.TryParse(oDirSitesString, out yDirSitesCount))
                {
                }

                break;
            }
            return new DefaultResult() {Value = yDirSitesCount, DomainName = url, Date = DateTime.Now};
        }
    }
}
